import request from "@/axios/request";
import { defineStore } from "pinia";
import { store } from "./store";
import { computed } from "vue";

export const usePluginConfigStore = defineStore("pluginConfig", () => {
  function addOrUpdateConfig( data) {
    return request.post({
      url: "/api/Plugin/AddOrUpdateConfig",
      method: "post",
      data: data,
      params: {
        id: data.id,
      },
    });
  }

  function getPluginApplyConfigs( params) {
    return request.get({
      url: "/api/Plugin/GetPluginApplyConfigs",
      method: "get",
      params: params,
    });
  }
  function getManifestWithConfigs( params) {
    return request.get({
      url: "/api/Plugin/GetManifestWithConfigs",
      method: "get",
      params: params,
    });
  }
  function loadPlugins( params) {
    return request.get({
      url: "/api/Plugin/LoadPlugins",
      method: "get",
      params: params,
    });
  }

  function getCustomizationVerifyExtensions( params) {
    return request.get({
      url: "/api/Plugin/GetCustomizationVerifyExtensions",
      method: "get",
      params: params,
    });
  }
  return {
    addOrUpdateConfig,
    getPluginApplyConfigs,
    getManifestWithConfigs,
    loadPlugins,
    getCustomizationVerifyExtensions,
  };
});

export const usePluginConfigWithOut = () => {
  return usePluginConfigStore(store);
};
